home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / rkey14.zip / RKEY.DOC < prev    next >
Text File  |  1991-02-07  |  20KB  |  587 lines

  1.  
  2.  
  3.                   rKey 1.4 (c) 1990, 1991 Serious Cybernetics
  4.                      Turbo Pascal(tm) Registration Key Unit
  5.                                by C. Scott Davis
  6.  
  7.  
  8. -------------------------------------------------------------------------------
  9.  
  10.  
  11. rKey is a small and simple version of a Turbo Pascal (tm) Registration Key Unit
  12. (similar to RkPlus).  It is designed to provide the most basic handling of
  13. registration keys, with a minimum of memory usage. All of the key encryption,
  14. checking and key file routines are handled in rKey, requiring little effort on
  15. the part of the programmer.  It can allow anything from simple registration
  16. messages to limiting program functions if the software is not registered.
  17.  
  18.  
  19. There are two versions of rKey included here. RKEY.TPU, which runs under Turbo
  20. Pascal (tm) 5.5 and RKEY6.TPU, which runs under Turbo Pascal (tm) 6.0.  For
  21. enhanced registration key handling (such as multiple encryption strings,
  22. registration levels and limited use demo keys) you should obtain a copy of
  23. RkPlus.  The latest version of rKey and RkPlus (as well as other Serious
  24. Cybernetics software) are always available for download and Fido file request
  25. from Phoenix StarFighter BBS (see phone number and Fido address below).
  26.  
  27.  
  28. All of the sample programs use RKEY.TPU.  If you have Turbo Pascal (tm) 6.0,
  29. and need to use rKey6, simply change :
  30.  
  31.   Uses
  32.     rKey;
  33.  
  34. to
  35.  
  36.   Uses
  37.     rKey6;
  38.  
  39.  
  40. The various sample programs demonstrate the 2 methods of handling keys :
  41.  
  42.   Method 1 : Distribute your program (for example, RKSAMPLE.EXE) and use
  43.              a key file generation program (like RKGENFIL.EXE), which you
  44.              do NOT distribute, to create a key file for each user who
  45.              registers.  You then send the user the key file.
  46.  
  47.   Method 2 : Distribute your program (for example, RKSAMPLE.EXE) and a
  48.              branding program (like RKBRAND.EXE).  You then use a key
  49.              generation program (like RKGENKEY.EXE), which you do NOT
  50.              distribute, to create a a key number for each user who
  51.              registers.  You then send the user the key number, which
  52.              he/she enters into the brand program to create a key file.
  53.  
  54.  
  55. -------------------------------------------------------------------------------
  56.  
  57.  
  58. The following constants are defined in rKey :
  59.  
  60.   rKeyVersion = '1.4';         { contains the current version of rKey }
  61.  
  62.  
  63. The following variables are defined in rKey :
  64.  
  65.   OwnerCode   : String[20];
  66.   ProgramCode : String[16];
  67.   KeyFileName : String[8];
  68.   KeyFilePath : String[79];
  69.   RegError    : Boolean;
  70.   RegStatus   : Boolean;
  71.   RegName     : String[36];
  72.   RegKey      : String[12];
  73.  
  74.  
  75. The following procedures and functions are defined in rKey :
  76.  
  77.   Function MakeKey(Name : String) : String;
  78.   Function ValidKey(Name : String; Key : String) : Boolean;
  79.   Procedure GetRegInfo;
  80.   Procedure Register(Name : String; Key : String);
  81.  
  82.  
  83. -------------------------------------------------------------------------------
  84.  
  85.  
  86. OwnerCode : String[20];
  87.  
  88. This variable is NOT initialized by rKey and MUST be set at the start of your
  89. program.  It is used (along with ProgramCode) to generate the registration
  90. keys.  This variable should probably be the same for all software written by a
  91. single person/company.  Since is it used to cause your keys to be different
  92. from those of other programmers who are also using rKey, the more cryptic this
  93. variable is, the more secure your keys will be.
  94.  
  95.  
  96. Examples :
  97.  
  98.   OwnerCode := 'TrendSoft, Inc.';
  99.  
  100. {
  101.  If the name of your company is 'TrendSoft, Inc.', this is probably NOT a good
  102.  OwnerCode.  It would be easy for someone who knows the name of the company
  103.  to use the rKey unit to write a program that will generate keys for your
  104.  software.
  105. }
  106.  
  107.   OwnerCode := 'Trend&&Soft/Inc@';
  108.  
  109. {
  110.  This is better.  It still uses the name of the company, but it is somewhat
  111.  masked by the insertion of other characters and would be harder for another
  112.  programmer to guess.
  113. }
  114.  
  115.   OwnerCode := 'Read$Make@Into';
  116.  
  117. {
  118.  This is MUCH better.  It uses totally unrelated words that would be extremely
  119.  unlikely to be used by another programmer/company.
  120. }
  121.  
  122.   OwnerCode := 'EkQW3#m,-%\uSaXo^Ej7';
  123.  
  124. {
  125.  This is most likely the best, since it uses totally random symbols.
  126. }
  127.  
  128. IMPORTANT : You should NOT use any of the actual examples used here or in
  129.             the sample programs included with rKey.  If you do, anyone else
  130.             who uses the same example will have IDENTICAL keys!
  131.  
  132.  
  133. -------------------------------------------------------------------------------
  134.  
  135.  
  136. ProgramCode : String[16];
  137.  
  138. This variable is NOT initialized by rKey and MUST be set at the start of your
  139. program.  It is used (along with OwnerCode) to generate the registration keys.
  140. There are several approaches to the use of ProgramCode :
  141.  
  142.   (1) If ProgramCode is set to the same value for several programs
  143.       written by a person/company, keys for one piece of software will
  144.       work on another piece of software.  Using this approach, you
  145.       could have a single key for several programs.
  146.  
  147.   (2) If each program has a different ProgramCode and the ProgramCode is
  148.       not changed when the program changes, keys for one version of the
  149.       program will work for all versions of the same program.
  150.  
  151.   (3) If each program has a differenct ProgramCode and the ProgramCode is
  152.       changed when the program is changed, a different key will be
  153.       required for each version of the program.
  154.  
  155.  
  156. Examples :
  157.  
  158.   ProgramCode := 'RkStuff';
  159.  
  160. {
  161.  If you wrote a program called RkSample and a program called RkUtils and
  162.  you defined the ProgramCode as 'RkStuff' in both programs, a key for one
  163.  program would work for the other.
  164. }
  165.  
  166.   ProgramCode := 'RkSample';
  167.  
  168. {
  169.  If you wrote a program called RkSample and a program called RkUtils and
  170.  you defined the ProgramCode as 'RkSample' in RkSample and used a different
  171.  ProgramCode in RkUtils, a key for one would NOT work for the other.
  172. }
  173.  
  174.   ProgramCode := 'RkSample One';
  175.  
  176. {
  177.  If you wrote a program called RkSample and you defined the ProgramCode as
  178.  'RkSample One' in versions 1.1, 1.2 and 1.3 and then changed the
  179.  ProgramCode to 'RkSample Two' for version 2.0, the same key would work for
  180.  versions 1.1, 1.2 and 1.3 but would NOT work for version 2.0.
  181. }
  182.  
  183.  
  184. -------------------------------------------------------------------------------
  185.  
  186.  
  187. KeyFileName : String[8];
  188.  
  189. This variable is NOT initialized by rKey and MUST be set at the start of your
  190. program.  It is the name of the keyfile that is read by GetRegInfo and written
  191. to by Register.  This will probably be the name of the program file.  The
  192. extension will be '.KEY'.
  193.  
  194.  
  195. Examples :
  196.  
  197.   KeyFileName := 'RKSAMPLE';
  198.  
  199. {
  200.  The key file will be 'RKSAMPLE.KEY'.  Key files are always created and read
  201.  from the same directory that the program is in.  This is true even if the
  202.  program is not in the current directory.
  203. }
  204.  
  205.  
  206. -------------------------------------------------------------------------------
  207.  
  208.  
  209. KeyFilePath : String[79];
  210.  
  211. This variable is initialized by rKey to ''.  GetRegInfo and Register will set
  212. KeyFilePath to the full directory, filename and extension of the key file.  If
  213. no key file was found, KeyFilePath will be set to ''.
  214.  
  215.  
  216. Examples :
  217.  
  218.   KeyFileName := 'RKSAMPLE';
  219.   GetRegInfo;
  220.   If KeyFilePath <> '' then
  221.     WriteLn('Key file is ' + KeyFilePath);
  222.  
  223. {
  224.  The key file will be 'RKSAMPLE.KEY'.  After GetRegInfo is called, KeyFilePath
  225.  will contain the full pathname of the the key file, which is displayed (if it
  226.  is not '').
  227. }
  228.  
  229.  
  230. -------------------------------------------------------------------------------
  231.  
  232.  
  233. RegError : Boolean;
  234.  
  235. This variable is initialized by rKey to FALSE.  It is set by GetRegInfo and
  236. Register to indicate an invalid key.  If RegError is TRUE after a call to
  237. GetRegInfo, it means that the key contained in the key file is invalid.  This
  238. probably means that the key file has been tampered with.  If RegError is set
  239. to TRUE after a call to Register, it means that the key that was passed to
  240. Register was invalid or the program was unable to create the key file; and the
  241. key file was NOT written.
  242.  
  243.  
  244. Examples :
  245.  
  246.   KeyFileName := 'RKDEMO';
  247.   GetRegInfo;
  248.   If RegError then
  249.     WriteLn('The key file has been altered!');
  250.  
  251. {
  252.  This will call GetRegInfo.  If the key contained in 'RKDEMO.KEY' is invalid,
  253.  the message 'The KEY file has been altered!' will be displayed.
  254. }
  255.  
  256.  
  257. -------------------------------------------------------------------------------
  258.  
  259.  
  260. RegStatus : Boolean;
  261.  
  262. This variable is initialized by rKey to FALSE.  It is set by GetRegInfo and
  263. Register to indicate the software is registered.  If RegStatus is TRUE then
  264. RegName and RegKey contain valid registration information.  If RegStatus is
  265. FALSE (after a call to GetRegInfo), the software is unregistered.
  266.  
  267.  
  268. Examples :
  269.  
  270.   KeyFileName := 'RKDEMO';
  271.   GetRegInfo;
  272.   Write('RkDemo v1.5');
  273.   If RegError then
  274.     WriteLn('[invalid key]')
  275.   Else If RegStatus then
  276.     WriteLn('[registered]')
  277.   Else
  278.     WriteLn('[unregistered]');
  279.  
  280. {
  281.  This will call GetRegInfo.  If the key contained in 'RKDEMO.KEY' is invalid,
  282.  the message 'RkDemo v1.5 [invalid key]' will be displayed.  If the program
  283.  is registered, the message 'RkDemo v1.5 [registered]' will be displayed.
  284.  Otherwise, the message 'RkDemo v1.5 [unregistered]' will be displayed.
  285. }
  286.  
  287.  
  288. -------------------------------------------------------------------------------
  289.  
  290.  
  291. RegName : String[36];
  292.  
  293. This variable is initialized by rKey to ''.  It is set by GetRegInfo and
  294. Register if the software is registered.  This variable only contains valid
  295. information if RegStatus is TRUE.
  296.  
  297.  
  298. Examples :
  299.  
  300.   KeyFileName := 'RKDEMO';
  301.   GetRegInfo;
  302.   Write('RkDemo v1.5');
  303.   If RegError then
  304.     WriteLn('[invalid key]')
  305.   Else If RegStatus then
  306.     WriteLn('[registered to ' + RegName + ']')
  307.   Else
  308.     WriteLn('[unregistered]');
  309.  
  310. {
  311.  This will call GetRegInfo.  If the key contained in 'RKDEMO.KEY' is invalid,
  312.  the message 'RkDemo v1.5 [invalid key]' will be displayed.  If the program
  313.  is registered, the message 'RkDemo v1.5 [registered to NAME]' will be displayed
  314.  (with 'NAME' replaced by the name of the person that the software is
  315.  registered to).  Otherwise, the message 'RkDemo v1.5 [unregistered]' will be
  316.  displayed.
  317. }
  318.  
  319.  
  320. -------------------------------------------------------------------------------
  321.  
  322.  
  323. RegKey : String[12];
  324.  
  325. This variable is initialized by rKey to '000000000000'.  It is set by
  326. GetRegInfo and Register if the software is registered.  This variable only
  327. contains valid information if RegStatus is TRUE.  This contains the
  328. 12 digit hexadecimal registration key as a string.
  329.  
  330.  
  331. Examples :
  332.  
  333.   KeyFileName := 'RKMORE';
  334.   GetRegInfo;
  335.   If RegError or Not RegStatus then Begin
  336.     WriteLn('This version of RkMore is not registered.');
  337.     WriteLn('Please read the READ.ME file for more info.');
  338.   End Else
  339.     WriteLn('This version of RkMore is registered to ' + RegName + '.');
  340.     WriteLn('Registration key is ' + RegKey + '.');
  341.   End;
  342.  
  343. {
  344.  This will call GetRegInfo.  If the key contained in 'RKMORE.KEY' is invalid
  345.  or the program is not registered, a message will be displayed telling the
  346.  user how to register the program.  Otherwise, the name of the person that
  347.  that the program is registered to and the registration key will be
  348.  displayed.
  349. }
  350.  
  351.  
  352. -------------------------------------------------------------------------------
  353.  
  354.  
  355. Function MakeKey(Name : String) : String;
  356.  
  357. The function MakeKey will return a string containing the 12 digit hexadecimal
  358. registration key for the Name passed to it (using the pre-defined values of
  359. OwnerCode and ProgramCode). This function is usually used to create
  360. registration keys or key files, in a program that is not distributed to the
  361. user.
  362.  
  363.  
  364. Examples :
  365.  
  366.   OwnerCode := 'AZ771N91P03DJSS447';
  367.   ProgramCode := 'RkProg';
  368.   WriteLn('Registration Key Maker for RkProg');
  369.   WriteLn;
  370.   WriteLn('FOR INTERNAL USE ONLY!');
  371.   WriteLn;
  372.   Write('Enter name : ');
  373.   ReadLn(n);
  374.   k := MakeKey(n);
  375.   WriteLn;
  376.   WriteLn('Registration key is '+k);
  377.  
  378. {
  379.  This will display a warning message and then prompt for a name.  MakeKey is
  380.  then passed the name and then returns the key in the variable k, which is then
  381.  displayed.
  382. }
  383.  
  384.  
  385. -------------------------------------------------------------------------------
  386.  
  387.  
  388. Function ValidKey(Name : String; Key : String) : Boolean;
  389.  
  390. ValidKey will return TRUE, if Key is valid for the name passed to it (using the
  391. pre-defined values of OwnerCode and ProgramCode). If ValidKey returns FALSE,
  392. the key is not valid.
  393.  
  394.  
  395. Examples :
  396.  
  397.   OwnerCode := 'dfk89ew32zg0imm02';
  398.   ProgramCode := 'RkProg One';
  399.   WriteLn('RkProg v1.4');
  400.   WriteLn;
  401.   Write('Enter your name : ');
  402.   ReadLn(n);
  403.   Write('Enter your registration key : ');
  404.   ReadLn(k);
  405.   If Not ValidKey(n,k) then Begin
  406.     WriteLn('Invalid key!');
  407.     Halt(1);
  408.   End;
  409.  
  410. {
  411.  This program will prompt the user to enter a name and a registration key.
  412.  If the registration key is not valid, the program will display 'Invalid key!'
  413.  and Halt with an errorlevel of 1.
  414. }
  415.  
  416.  
  417. -------------------------------------------------------------------------------
  418.  
  419.  
  420. Procedure GetRegInfo;
  421.  
  422. GetRegInfo will read the key file (if it exists) and set the value of the
  423. following variables :
  424.  
  425.   RegError    { set to TRUE if the key file contains an invalid key }
  426.   RegStatus   { set to TRUE if the software is registered }
  427.   RegName     { set to the name of the person the software is registered to }
  428.   RegKey      { set to the 12 digit hexadecimal registration key }
  429.  
  430. GetRegInfo would generally be called near the beginning of a program (after
  431. OwnerCode, ProgramCode and KeyFileName are defined).
  432.  
  433.  
  434. Examples :
  435.  
  436.   OwnerCode := '&,<;(##@["+|~~**=#))';
  437.   ProgramCode := 'RkTest';
  438.   KeyFileName := 'RKTEST';
  439.   GetRegInfo;
  440.   If Not RegError then
  441.     If RegStatus then
  442.       WriteLn('Registered to ' + RegName);
  443.  
  444. {
  445.  GetRegInfo will read 'RKTEST.KEY'.  If it contains an invalid key, RegError
  446.  will be set.  If it doesn't exist, RegStatus will be set to FALSE.  Otherwise,
  447.  The various registration variables will be set.  The program then displays
  448.  the name of the person that the program is registered to.
  449. }
  450.  
  451.  
  452. -------------------------------------------------------------------------------
  453.  
  454.  
  455. Procedure Register(Name : String; Key : String);
  456.  
  457. Register will update the key file (creating it, if it doesn't exist) and set
  458. the value of the following variables :
  459.  
  460.   RegError    { set to TRUE if the Key parameter is invalid }
  461.               { or the file can NOT be created              }
  462.   RegStatus   { set to TRUE }
  463.   RegName     { set to the Name parameter }
  464.   RegKey      { set to the Key parameter }
  465.  
  466. If the Key parameter is invalid, RegError will be set to TRUE, the key file
  467. will NOT be written and the values of the other registration variables will
  468. NOT be changed.  Register would generally be called by an install or branding
  469. program of some type.  It can also be used by a key creation program, which
  470. is not distributed (if you want to send key files to registered users, rather
  471. than a key that they would enter).
  472.  
  473.  
  474. Examples :
  475.  
  476.   OwnerCode := 'Keyboard*Sytem=Load';
  477.   ProgramCode := 'RkProg';
  478.   KeyFileName := 'RKPROG';
  479.   WriteLn('RkProg Install Program');
  480.   WriteLn;
  481.   Write('Enter your name : ');
  482.   ReadLn(n);
  483.   Write('Enter your registration key : ');
  484.   ReadLn(k);
  485.   Register(n,k);
  486.   If RegError then
  487.     WriteLn('Invalid Key.  Program not installed.');
  488.  
  489. {
  490.  This program will prompt the user for a name and a registration key.  Register
  491.  will then be passed the name and the key.  If RegError is TRUE, the key was
  492.  invalid and no key file was written (the program displays 'Invalid Key.
  493.  Program not installed.').  Otherwise, RKPROG.KEY is written and the
  494.  registration variables are set.
  495. }
  496.  
  497.  
  498. -------------------------------------------------------------------------------
  499.  
  500.  
  501. For more information on using rKey, see the sample Turbo Pascal (tm) programs
  502. that are distributed with rKey, or contact me at any of the locations listed
  503. below.
  504.  
  505.  
  506. -------------------------------------------------------------------------------
  507.  
  508.  
  509. rKey is shareware. You may copy and distribute RKEY14.ZIP freely.  All I ask is
  510. that you include all of the original files, unmodified, and that you do not
  511. charge for the distribution of rKey itself.  You may use rKey for development
  512. of programs for your own use, to give away or to sell.
  513.  
  514.  
  515. If you like rKey and use it to develop software, a registration fee of $10
  516. or more toward the continued development of this unit and others like it
  517. would be appreciated.  See REGISTER.FRM for registration information.
  518.  
  519.  
  520. Everyone registering rKey with a registration fee of $10 or more, will be
  521. entitled to have one piece of software (written using rKey/RkPlus) listed,
  522. along with an address or phone number, in an application list that will be
  523. included with all future versions of rKey/RkPlus.  Registrations of $20 or
  524. more, will register both rKey AND RkPlus (available as RKPLUS20.ZIP), allowing
  525. you to develop and distribute programs using either one, or both. Registrations
  526. in excess of $20 will allow multiple applications to be listed.
  527.  
  528.  
  529. There are no royalties for the distribution of programs that are written
  530. with rKey.  A single registration fee entitles you to write and distribute
  531. any number of programs using rKey.
  532.  
  533.  
  534. If you have written an application using rKey/RkPlus, and wish to have it
  535. listed in the APPLIST.TXT file that is distributed with rKey/RkPlus, please
  536. send the following information via E/Mail, NetMail or US Mail :
  537.  
  538.   Name of Application
  539.   Programmer's Name (optional)
  540.   Copyright Notice
  541.   Address or Phone Number
  542.   System Requirements
  543.   Cost of Program (optional)
  544.   Any Additional Information (optional)
  545.  
  546.  
  547. Questions, comments, and suggestions are welcome.
  548.  
  549. Send E/Mail to   Scott Davis
  550.                  Phoenix StarFighter BBS [3/12/24/HST)
  551.                  Phone (404) 869-3410
  552.                  FidoNet Node 1:3616/20
  553.  
  554. Send US Mail to  Scott Davis
  555.                  Rt. 2 Box 95
  556.                  County Line Drive
  557.                  Lula, GA 30554
  558.  
  559.  
  560. -------------------------------------------------------------------------------
  561.  
  562.  
  563. I'd like to thank Danny Sosebee (Sysop of Phoenix StarFighter BBS) for
  564. allowing me to use his BBS as a way to receive suggestions and comments
  565. regarding rKey.  Also, I'd like to thank Ed Ivey (Sysop of Ed's Place
  566. BBS - 404/532-1978 - FidoNet Node 1:3616/1) for his continued support
  567. and assistance in distributing my little software "projects".
  568.  
  569.  
  570. -------------------------------------------------------------------------------
  571.  
  572.  
  573.       Turbo Pascal (tm) units available from Serious Cybernetics :
  574.  
  575.           StrLib 1.2          TP 5.5 String Functions Library Unit
  576.           rKey 1.4            TP 5.5/6.0 Registration Key Unit
  577.           RkPlus 2.0          TP 5.5/6.0 Registration Key Unit (enhanced)
  578.  
  579.  
  580. ------------------------------------------------------------------------------
  581.  
  582. RkPlus (c) 1991 Serious Cybernetics
  583. rKey, StrLib (c) 1990, 1991 Serious Cybernetics
  584. Turbo Pascal (c) 1983, 1989 Borland International
  585.  
  586.  
  587.